﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CalendarApplication
{
    public partial class frmRegister : Form
    {
        public frmRegister()
        {
            this.StartPosition = FormStartPosition.CenterScreen;
            InitializeComponent();
        }

        private void btnRegister_Click(object sender, EventArgs e)
        {
            lblPasswordError.Visible = false;
            lblUserError.Visible = false;
            CalendarServiceRef.CalendarServiceClient sr = new CalendarServiceRef.CalendarServiceClient();
            string un = txtUsername.Text.ToString();
            string pw = txtPassword.Text.ToString();

            if (txtPassword.Text.ToString() == txtConfirmPassword.Text.ToString())
            {
                sr.Register(un, pw);
                this.Close();
            }
            else
            {
                lblPasswordError.Visible = true;
                txtPassword.Clear();
                txtConfirmPassword.Clear();
                txtPassword.Focus();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void txtUsername_Validating(object sender, CancelEventArgs e)
        {
            CalendarServiceRef.CalendarServiceClient sr = new CalendarServiceRef.CalendarServiceClient();
            //check if user exists in db
            
        }
    }
}
